﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using S7.Net;

namespace S7.NET
{
    public class S7cs
    {
        //static Con
        //Plc plc = new Plc(CpuType.S71200, "6.6.6.30", 0, 2);

        public static Plc objS7net;

        public static bool openplc(CpuType cpuType,string ip)
        {
            objS7net = new Plc(cpuType, ip, 0, 1);
            try
            {
                objS7net.Open();
                return true;
            }
            catch { return false; }

        }

        public static bool closeplc()
        {
            try
            {
                objS7net.Close();
                return true;
            }
            catch (Exception)
            {

                return false; ;
            }
        }

        public static string read(string value_address) {
           return objS7net.Read(value_address).ToString();
        }

        
    }
}
